import request from '@/utiles/request.js'

export const getPostLikesService = async () => request.get('/postinfo/getlikes')

export const getPostCollectService = async () => request.get('/postinfo/getcollects')

export const delPostLikeService = async (id) => request.delete(`/postinfo/dellike/${id}`)

export const delPostCollectService = async (id) => request.delete(`/postinfo/delcollect/${id}`)

export const addPostLikeService = async (id) => request.put(`/postinfo/addlike/${id}`)

export const addPostCollectService = async (id) => request.put(`/postinfo/addcollect/${id}`)

export const addPostViewsService = async (id) => request.put(`/postinfo/addviews/${id}`)

//返回我点赞过的文章
export const getLikesPostService = async () => {
  return await request.get('/postinfo/getpost/likes')
}

//返回我收藏的文章
export const getCollectsPostService = async () => {
  return await request.get('/postinfo/getpost/collects')
}

//返回我的浏览记录
export const getViewsPostService = async () => {
  return await request.get('/postinfo/getpost/views')
}

// 获取用户所有收藏分类
export const getCollectCategories = async () => {
  return await request.get('/postinfo/collect/category')
}

// 创建新收藏分类
export const createCollectCategory = async (categoryData) => {
  return await request.post('/postinfo/collect/addCategory', categoryData)
}

// 更新收藏分类
export const updateCollectCategory = async (category) => {
  return await request.put('/postinfo/category',category)
}

// 删除收藏分类
export const deleteCollectCategory = async (id) => {
  return await request.delete(`/postinfo/category/${id}`)
}

export const addPostCollectByCategory = async (category) => {
  return await request.post('/postinfo/addcollect/category',category)
}
export const getPostByCategory = async (categoryId) => {
  return await request.get('/postinfo/collect/post/category', {
    params: {
      categoryId: categoryId
    }
  })
}









